package com.yituo.mjworld.mvc.entity.web;

import com.yituo.mjworld.core.annotation.Rules;
import com.yituo.mjworld.core.web.core.BaseForm;

import javax.persistence.*;

/**
 * 实体类.
 * 经过改造后成为表单类.
 * <p>
 * 兼容相关的实体责任和表单责任
 */
@Entity
@Table(name = "web_parent_item", schema = "web_mojianworld_server", catalog = "")
public class WebParentItem extends BaseForm {
  @Rules(fieldName = "ID", id = true)
  public int id;
  @Rules(fieldName = "分类名称")
  public String title;
  @Rules(fieldName = "排序的序列号", min = "0")
  public int orderNum;

  @Id
  @Column(name = "id", nullable = false)
  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  @Basic
  @Column(name = "title", nullable = false, length = 50)
  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  @Basic
  @Column(name = "orderNum", nullable = false)
  public int getOrderNum() {
    return orderNum;
  }

  public void setOrderNum(int orderNum) {
    this.orderNum = orderNum;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    WebParentItem that = (WebParentItem) o;

    if (id != that.id) {
      return false;
    }
    if (orderNum != that.orderNum) {
      return false;
    }
    if (title != null ? !title.equals(that.title) : that.title != null) {
      return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int result = id;
    result = 31 * result + (title != null ? title.hashCode() : 0);
    result = 31 * result + orderNum;
    return result;
  }

  @Override
  public boolean validate() {
    return defaultValidate();
  }
}
